package com.unidt.bridge;

import com.unidt.conf.ConfFactory;
import com.unidt.conf.IConf;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;


/**
 * 调用分维引擎，此处指通知引擎开始离线、批量打标签
 */
public class CallFraEngine {

    private Logger log = LoggerFactory.getLogger(CallFraEngine.class);

    public void get(String url) {

    }

    public void startOffline() throws IOException {
        IConf conf = ConfFactory.createPropertyConfig("service.properties");
        String url = conf.getString("fra_url");

        HttpClient client = new HttpClient();
        client.getHttpConnectionManager().getParams().setConnectionTimeout(15000);

        GetMethod get = new GetMethod(url);
        get.getParams().setParameter(HttpMethodParams.SO_TIMEOUT,60000);

        int statusCode = client.executeMethod(get);
        if (statusCode == 200) {
            byte[] responseBody = get.getResponseBody();
            String strBody = new String(responseBody);
            log.info(strBody);
        }else {

        }
    }

    public static void main(String[] args) throws IOException {
        CallFraEngine engine = new CallFraEngine();
        engine.startOffline();
    }
}
